package com.feihao.zhou.demo04SerilazableTest;

import java.io.*;

public class TestDemo01 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {

        Student student1 = new Student(78,"Tom");
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("s.txt"));
        oos.writeObject(student1);
        oos.close();

        //反序列化：
        ObjectInputStream ois = new ObjectInputStream(new FileInputStream("s.txt"));
        Object o = ois.readObject();
        if (o instanceof Student){
            Student s = (Student) o;
            System.out.println(s);
        }
    }
}
